﻿@{
    Layout = "~/Views/Shared/_Index.cshtml";
}
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="post-form">
                <div class="select-list">
                    <ul>
                        <li>
                            标题：<input type="text" name="newsTitle" />
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" >
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="gridTable"></table>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        var options = {
            id: "gridTable",
            url: "/OrganizationManage/News/GetPageListJson",
            createUrl: "/OrganizationManage/News/NewsForm",
            updateUrl: "/OrganizationManage/News/NewsForm",
            removeUrl: "/OrganizationManage/News/DeleteFormJson",
            exportUrl: "",
            modalName: "文章",
            sortName: 'NewsSort',
            sortOrder: 'Desc',
            columns: [
                { checkbox: true, visible: true },
                { field: 'newsTitle', title: '文章标题' },
                {
                    field: 'newsType', title: '文章类型', formatter: function (value, row, index) {
                        //新闻类型(1产品案例 2行业新闻)
                        var str;
                        switch (row.newsType) {
                            case 1: str = "产品案例"; break;
                            case 2: str = "行业新闻"; break;
                        }
                        return str;
                    }
                },
                { field: 'newsAuthor', title: '作者' },
                { field: 'newsSort', title: '排序' },
                { field: 'newsDate', title: '发布时间',sortable: true },
                { field: 'niewTimes', title: '阅读量', sortable: true},
            ],
            onClickRow: function (row, element) {
                element[0].firstElementChild.firstElementChild.click();
            }
        };
        $.table.init(options);
    });
</script>
